def test_cnf_ans(cnf,ans):
    if len(ans) == 0:
        return True
    for clause in cnf:
        flag = False
        for literal in clause:
            abs_li = abs(literal)
            if (literal<0 and ans[abs_li-1]<0) or (literal>0 and ans[abs_li-1]>0):
                flag = True
                break
        if not flag:
            return False
    return True